package com.lcn.core.service.aop;

import com.lcn.comm.domain.TxTransactionInfo;
import com.lcn.comm.service.aop.TransactionService;
import com.lcn.comm.util.DateUtil;
import com.weibo.api.motan.util.LoggerUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.stereotype.Service;

/**
 * <p>默认事务</p>
 *
 * @author 张峰 zfvip_it@163.com
 * @create: 2017-12-25 18:21
 */
@Service("defaultTransactionService")
public class DefaultTransactionServiceImpl implements TransactionService {

    /**
     * 事务逻辑处理
     *
     * @param point
     * @param info
     * @return
     * @throws Throwable
     */
    public Object execute(ProceedingJoinPoint point, TxTransactionInfo info) throws Throwable {
        Long startTime = System.currentTimeMillis();
        Object obj = point.proceed();
        LoggerUtil.info("default proceed耗时[{}]", DateUtil.dateDiff(startTime, System.currentTimeMillis()));
        return obj;
    }
}
